//
//  Created by matt on 28/09/12.
//

#import "PhotoBox.h"
#import "UIImageExtras.h"
#import <QuartzCore/QuartzCore.h>

@implementation PhotoBox

#define SPINNER_TAG 100

#pragma mark - Init

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor colorWithRed:0.94 green:0.94 blue:0.95 alpha:1];
        
        self.layer.shadowColor = [UIColor colorWithWhite:0.12 alpha:1].CGColor;
        self.layer.shadowOffset = CGSizeMake(0, 0.5);
        self.layer.shadowRadius = 1;
        self.layer.shadowOpacity = 1;
        
//        UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
//        spinner.center = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2);
//        spinner.color = UIColor.lightGrayColor;
//        spinner.tag = SPINNER_TAG;
//        [spinner startAnimating];
//        [self addSubview:spinner];
    }
    return self;
}

-(void)startIndicator:(BOOL)isStart{
    UIActivityIndicatorView *spinner = self.subviews.lastObject;
    if(isStart)
        [spinner startAnimating];
    else 
        [spinner stopAnimating];
}

-(void)setImage:(UIImage *)image{  
    [image forceLoad];
    [super setImage:image];
    
  //  if(image)
    //    [self startIndicator:FALSE];
}

#pragma mark - Layout

- (void)layoutSubviews {
  [super layoutSubviews];
  self.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.bounds].CGPath;
}



@end
